import Vuex from 'vuex'  // uniapp自带vuex插件，可以直接导入
import Vue from 'vue'

Vue.use(Vuex)

const store = new Vuex.Store({
    state: {
			globalPlayStatus: false,
			globalPlayList: [],
			curMusicInfo: {},
			curTapIndex: null,
			globalSheetSongListInfo: null
    },
    mutations: {
				// 改变播放状态
				changePlayStatus(state){
					state.globalPlayStatus = true
					console.log('storeJs.mutations.globalPlayStatus：', state.globalPlayStatus);
				},
				changeStopStatus(state){
					state.globalPlayStatus = false
					console.log('storeJs.mutations.globalPlayStatus：', state.globalPlayStatus);
				},
				// 增加单个歌曲存入全局歌单
				pushGlobalPlayList(state, song) {
						state.globalPlayList.push(song)
						// console.log('storeJs.mutations.this：', this);
            console.log('storeJs.state.globalPlayList', state.globalPlayList)
        },
        // 更换歌单列表数据(点击"全部播放"时调用)
        changeGlobalPlayList(state, playList) {
						state.globalPlayList = playList
						// console.log('storeJs.mutations.this：', this);
            console.log('storeJs.state.globalPlayList', state.globalPlayList)
        },
				changeCurMusicInfo(state, curMusicInfo){
					state.curMusicInfo = curMusicInfo
					console.log('storeJs.state.curMusicInfo:', state.curMusicInfo)
				},
				changeCurTapIndex(state, index){
					state.curTapIndex = index
					console.log('storeJs.state.curTapIndex:', state.curTapIndex)
				},
				updateGlobalSheetSongListInfo(state, list){
					state.globalSheetSongListInfo = list
					console.log('storeJs.state.globalSheetSongListInfo:', state.globalSheetSongListInfo)
				}
				
    }
})

export default store
